package structure.filter;

import java.util.ArrayList;
import java.util.List;

/**
 * 过滤器模式（标准模式）
 *
 * @author yeyangtao
 * @date 2020/6/23 14:38
 */
public class Demo {
    public static void main(String[] args) {
        List<Person> persons = new ArrayList<>();

        persons.add(new Person("Robert", "Male", "Single"));
        persons.add(new Person("John", "Male", "Married"));
        persons.add(new Person("Laura", "Female", "Married"));
        persons.add(new Person("Diana", "Female", "Single"));
        persons.add(new Person("Mike", "Male", "Single"));
        persons.add(new Person("Bobby", "Male", "Single"));


        Criteria single = new CriteriaSingle();
        Criteria female = new CriteriaFemale();
        Criteria male = new CriteriaMale();

        Criteria singleMale = new AndCriteria(single, male);
        Criteria maleFemale = new OrCriteria(male, female);

        List<Person> andList = singleMale.meetCriteria(persons);
        List<Person> orList = maleFemale.meetCriteria(persons);
        System.out.println(andList);
        System.out.println(orList);
    }
}
